package innerclass;

public class OuterClass {
    private int i = 10;
    private static int j = 100;
    public class InnerOne{
        public void method1(){
            System.out.println("i = " + i);
            System.out.println("j = " + j);
            System.out.println("method1方法执行！");
        }
        public static void method2(){
            System.out.println("j = " + j);
            System.out.println("method2方法执行！");
        }
    }
    public static class InnerTwo{
        public void method3(){
            System.out.println("j = " + j);
            System.out.println("method3方法执行！");
        }
        public static void method4(){
            System.out.println("j = " + j);
            System.out.println("method2方法执行！");
        }
    }
    public void method5(){
        int x = 9;
        class InnerThree{
            public void method6(){
                System.out.println("i = " + i);
                System.out.println("j = " + j);
                System.out.println("x = " + x);
                System.out.println("method5中的内部类InnerThree中的method6方法执行！");
            }
        }
        InnerThree innerThree = new InnerThree();
        innerThree.method6();
    }

    public void method8(Ixxx i){
        i.method7();
    }
}
interface Ixxx{
    void method7();
}
class Test{
    public static void main(String[] args) {
        OuterClass.InnerOne innerOne = new OuterClass().new InnerOne();
        innerOne.method1();
        OuterClass.InnerOne.method2();

        OuterClass.InnerTwo innerTwo = new OuterClass.InnerTwo();
        innerTwo.method3();
        OuterClass.InnerTwo.method4();

        OuterClass outerClass = new OuterClass();
        outerClass.method5();

        outerClass.method8(new Ixxx() {
            @Override
            public void method7() {
                System.out.println("Ixxx中的method7已被实现！");
            }
        });
    }
}
